-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Port #[custom_mir(..)]
to the new attribute system
#145206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_hir/src/attrs Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
This comment has been minimized.
This comment has been minimized.
let (dialect, span) = dialect?; | ||
|
||
let dialect = match dialect.as_str() { | ||
"analysis" => MirDialect::Analysis, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can match directly on symbols here, so sym::analysis
|
||
let phase = match phase.as_str().to_ascii_lowercase().as_str() { | ||
"initial" => MirPhase::Initial, | ||
"post_cleanup" | "post-cleanup" | "postcleanup" => MirPhase::PostCleanup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the original impl have 3 variants? This feels like something that should be specified and then changed to one of these 3
|
||
#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] | ||
#[derive(HashStable_Generic, PrintAttribute)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did i end up inserting a newline here?!
return; | ||
}; | ||
|
||
let string_of_dialect = || match dialect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could implement a trait that allows these to be used in diagnostics directly. I forgot which, maybe IntoDiagnosticsValue? Something like that. It's from rustc_errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inherent method name
is usually a simple enough way to do that.
compiler/rustc_middle/src/mir/mod.rs
Outdated
} | ||
} | ||
} | ||
|
||
impl RuntimePhase { | ||
pub fn parse(phase: Option<String>) -> Self { | ||
pub fn parse(phase: Option<attrs::MirPhase>) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method be inlined into its use sites now that it's so simple? Like the other *Phase::parse
?
return; | ||
}; | ||
|
||
let string_of_dialect = || match dialect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inherent method name
is usually a simple enough way to do that.
@cjgillot yea I told sasha off-github the same yesterday. Let's just collapse all those alternate syntaxes into one and make them symbols. :) |
(i'm kinda busy trying to unbreak the tests, i'll go through all these discussions once i have something that works (i was convinced i ran the tests before opening the PR, but apparently no --')) |
22677db
to
4acaec2
Compare
@cjgillot @jdonszelmann I think I addressed everything you raised in this PR :) |
This comment has been minimized.
This comment has been minimized.
4acaec2
to
e854013
Compare
awesome, looks good! @bors r+ rollup |
…szelmann Port `#[custom_mir(..)]` to the new attribute system r? `@jdonszelmann`
…szelmann Port `#[custom_mir(..)]` to the new attribute system r? ``@jdonszelmann``
…szelmann Port `#[custom_mir(..)]` to the new attribute system r? ```@jdonszelmann```
e854013
to
17d11f6
Compare
@rustbot ready |
@bors r+ |
…szelmann Port `#[custom_mir(..)]` to the new attribute system r? `@jdonszelmann`
17d11f6
to
a42cc37
Compare
@bors r+ (the other one has had some delays) |
@bors r- |
Apparently #145085 is ready - I'll rebase this PR once it is merged :D |
r? @jdonszelmann